home *** CD-ROM | disk | FTP | other *** search
- /*
- * matteFalloff.sl
- *
- * Like the matte shader, but with an additional falloff control that
- * controls the size of the falloff region; values between 0 and .5
- * make the falloff be over a smaller range, while values between .5
- * and 1 make the falloff be over a larger range.
- *
- * Matt Pharr <mmp@exluna.com>
- */
-
- float bias(varying float value, b) {
- float ret = 0;
- if (b > 0) ret = pow(value, log(b) / log(0.5));
- return ret;
- }
-
- float gain(float value, g) {
- return .5 * ((value < .5) ? bias(2*value, 1-g) :
- (2 - bias(2-2*value, 1-g)));
- }
-
- surface matteFalloff(float Ka = 1, Kd = 1, falloff = 0.5) {
- normal Nf = normalize(faceforward(N, I));
- illuminance(P, Nf, PI/2) {
- Ci += Kd * Cl * gain(Nf . normalize(L),
- clamp(falloff, 0, 1));
- }
- Ci += Ka * ambient();
- Ci *= Cs;
- }
-
-